﻿#include "StatusBarWidget.h"
#include "ui_StatusBarWidget.h"

StatusBarWidget::StatusBarWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::StatusBarWidget)
{
    ui->setupUi(this);
    QFontMetrics fm(ui->labelMousePosition->font());
    ui->labelMousePosition->setMinimumWidth(fm.size(Qt::TextSingleLine, "(1920.000, 1080.000)").width() + 10);
    ui->labelCameraName->setMinimumWidth(fm.size(Qt::TextSingleLine, "Camera: Unknow Camera").width() + 10);
    ui->labelCameraResolution->setMinimumWidth(fm.size(Qt::TextSingleLine, "Resolution: (640, 480)").width() + 10);
    ui->labelCameraFrameCount->setMinimumWidth(fm.size(Qt::TextSingleLine, "FrameCount: 99999").width() + 10);
    ui->labelCameraFrameRate->setMinimumWidth(fm.size(Qt::TextSingleLine, "FrameRate: 999").width() + 10);
}

StatusBarWidget::~StatusBarWidget()
{
    delete ui;
}

void StatusBarWidget::setCameraName(QString name)
{
    ui->labelCameraName->setText(tr("Camera: %1").arg(name));
}

void StatusBarWidget::setMousePos(QPointF &p)
{
    ui->labelMousePosition->setText(QString("(%1, %2)").arg(p.x()).arg(p.y()));
}

void StatusBarWidget::setFrameCount(int count)
{
    ui->labelCameraFrameCount->setText(tr("FrameCount: %1").arg(count));
}
void StatusBarWidget::setFrameRate(double fps)
{
    ui->labelCameraFrameRate->setText(tr("FrameRate: %1 fps").arg(fps));
}
void StatusBarWidget::setResolution(int x, int y)
{
    ui->labelCameraResolution->setText(tr("Resolution: (%1, %2)").arg(x).arg(y));
}
